package com.prd.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.prd.config.LoginInterceptor;
import com.prd.mapper.EntContactForeignAcceptorMapper;
import com.prd.model.EntContactForeignAcceptor;
import com.prd.model.LoginUser;
import com.prd.service.EntContactForeignAcceptorService;
import com.prd.util.UserInfoUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EntContactForeignAcceptorServiceImpl extends ServiceImpl<EntContactForeignAcceptorMapper, EntContactForeignAcceptor> implements EntContactForeignAcceptorService {

    @Autowired
    private EntContactForeignAcceptorMapper entContactForeignAcceptorMapper;

    @Override
    public int insertInfo(EntContactForeignAcceptor entContactForeignAcceptor) {
        LoginUser loginUser = LoginInterceptor.threadLocal.get();
        BeanUtils.copyProperties(UserInfoUtil.recordInfo(loginUser.getId(), loginUser.getName(), true), entContactForeignAcceptor);
        return entContactForeignAcceptorMapper.insert(entContactForeignAcceptor);
    }

    @Override
    public int updateInfo(EntContactForeignAcceptor entContactForeignAcceptor) {
        LoginUser loginUser = LoginInterceptor.threadLocal.get();
        BeanUtils.copyProperties(UserInfoUtil.recordInfo(loginUser.getId(), loginUser.getName(), false), entContactForeignAcceptor);
        return entContactForeignAcceptorMapper.updateById(entContactForeignAcceptor);
    }
}
